//101
import BTree from "./index.js";
function isSymmertric(root) {
  const vals = [];
  let index = 0;
  let result = true;
  function travel1(node) {
    if (node === null) {
      vals.push(null);
      return;
    }
    vals.push(node.val);
    travel1(node.left);
    travel1(node.right);
  }
  function travel2(node) {
    if (!result) return;
    if (node === null) {
      result = vals[index++] === null;
      return;
    }
    result = vals[index++] === node.val;
    travel2(node.right);
    travel2(node.left);
  }
  travel1(root.left);
  travel2(root.right);
  return result;
}
const tree = new BTree([1, 2, 2, 3, 4, 4, 3]);
console.log(isSymmertric(tree));
